//
//  Message.m
//  11-QQ聊天
//
//  Created by wangneihan on 15/12/21.
//  Copyright © 2015年 wangneihan. All rights reserved.
//

#import "Message.h"

@implementation Message

-(instancetype)initWithDic:(NSDictionary *)dic{
    if (self = [self init]) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+(instancetype)msgWithDic:(NSDictionary *)dic{
    return [[self alloc]initWithDic:dic];
}

+(NSArray *)message{
    NSString *path = [[NSBundle mainBundle]pathForResource:@"messages" ofType:@"plist"];
    NSArray *array = [NSArray arrayWithContentsOfFile:path];
    NSMutableArray *resultArray = [NSMutableArray array];
    Message *proMsg ;
    for (NSDictionary *dic in array) {
        Message *msg = [self msgWithDic:dic];
        msg.hiddenTime = [msg.time isEqualToString:proMsg.time];
        [resultArray addObject:msg];
        proMsg = msg;
    }
    return resultArray;
}

@end
